
clear
*want to use the already created tech instrument, which gives us mean tech by commuting zone and occupation


 
 use "$dir/data/interim/mean_tech_by_cz_census_2016_collapsed.dta", clear 
 
 
 merge m:1  census2010 czone using "$dir/data/interim/fixed_ind_czone_occ_weight_2000.dta"
 
 keep if _merge ==3

*constructing the instrument:
gen instrument_mean_ind_2000 = mean_count_tech_oth_czs * occ_share
gen instrument_any_ind_2000 = mean_any_tech_oth_czs * occ_share
gen fs_mean_ind_2000 = mean_any_tech * occ_share
gen fs_any_ind_2000 = mean_count_tech * occ_share

gen inst_mean_oas_ind_2000 = mean_count_tech_oth_czs * occ_share_oas
gen inst_any_oas_ind_2000 = mean_any_tech_oth_czs * occ_share_oas

gen fs_mean_oas_ind_2000 = mean_any_tech * occ_share_oas
gen fs_any_oas_ind_2000 =mean_count_tech * occ_share_oas

gen instrument_office_ind_2000 = mean_office_oth_czs *  occ_share
gen instrument_excel_ind_2000 =  mean_excel_oth_czs * occ_share

gen instrument_office_oas_ind_2000 = mean_office_oth_czs *  occ_share_oas
gen instrument_excel_oas_ind_2000 =  mean_excel_oth_czs * occ_share_oas


*collapse (sum) instrument_mean (sum) instrument_any (sum) fs_mean (sum) fs_any (min) czone_oas, by (year czone)
collapse (sum) instrument_mean_ind_2000 (sum) instrument_any_ind_2000 (sum) fs_mean_ind_2000 (sum) fs_any_ind_2000 (sum) inst_mean_oas_ind_2000 ///
(sum) instrument_office_ind_2000 (sum) instrument_excel_ind_2000 ///
(sum) inst_any_oas_ind_2000 (sum) fs_mean_oas_ind_2000 (sum) fs_any_oas_ind_2000 ///
(sum) instrument_office_oas_ind_2000 (sum) instrument_excel_oas_ind_2000, by (year czone)

drop if year<2007

save "$dir/data/interim/cz_tech_instrument_ind_2000.dta", replace

***

*now lets do this for the 1970s


 use "$dir/data/interim/mean_tech_by_cz_census_2016_collapsed.dta", clear
 
 merge m:1  census2010 czone using "$dir/data/interim/fixed_ind_czone_occ_weight_1970.dta"
 
 
 keep if _merge ==3

 

local year 1970
*constructing the instrument:
gen instrument_mean_ind_`year' = mean_count_tech_oth_czs * occ_share
gen instrument_any_ind_`year' = mean_any_tech_oth_czs * occ_share
gen fs_mean_ind_`year' = mean_any_tech * occ_share
gen fs_any_ind_`year' = mean_count_tech * occ_share

gen inst_mean_oas_ind_`year' = mean_count_tech_oth_czs * occ_share_oas
gen inst_any_oas_ind_`year' = mean_any_tech_oth_czs * occ_share_oas

gen fs_mean_oas_ind_`year' = mean_any_tech * occ_share_oas
gen fs_any_oas_ind_`year' =mean_count_tech * occ_share_oas

gen instrument_office_ind_`year' = mean_office_oth_czs *  occ_share
gen instrument_excel_ind_`year' =  mean_excel_oth_czs * occ_share

gen instrument_office_oas_ind_`year' = mean_office_oth_czs *  occ_share_oas
gen instrument_excel_oas_ind_`year' =  mean_excel_oth_czs * occ_share_oas


*collapse (sum) instrument_mean (sum) instrument_any (sum) fs_mean (sum) fs_any (min) czone_oas, by (year czone)
collapse (sum) instrument_mean_ind_`year' (sum) instrument_any_ind_`year' (sum) fs_mean_ind_`year' (sum) fs_any_ind_`year' (sum) inst_mean_oas_ind_`year' ///
(sum) instrument_office_ind_`year' (sum) instrument_excel_ind_`year' ///
(sum) inst_any_oas_ind_`year' (sum) fs_mean_oas_ind_`year' (sum) fs_any_oas_ind_`year' ///
(sum) instrument_office_oas_ind_`year' (sum) instrument_excel_oas_ind_`year', by (year czone)

drop if year<2007

save "$dir/data/interim/cz_tech_instrument_ind_`year'.dta", replace
